﻿<template>
    <div class="l-rblock l-form-viewer" style="padding:8px;">
        <el-form
            :model="formData"
            :rules="rules"
            size="mini"
            labelPosition="right"
            labelWidth="80px"
            ref="form"
            >
            <div class="l-auto-window only-tabs">
                <el-tabs v-model="activeName" type="card">
                    <el-tab-pane class="l-tabs-container" :label="$t('主表信息')" name="tab0">
                        <el-row :gutter="0">
                            <div class="l-rblock">
                                <el-col v-if="lr_formLookAuth('lr_sass_tenantgroup_f_Name')" :span="24" >
                                    <el-form-item 
                                        :label="$t('名称')" 
                                        prop="lr_sass_tenantgroup_f_Name"
                                        > 
                                        <el-input :disabled="!lr_formEditAuth('lr_sass_tenantgroup_f_Name')" v-model="formData.lr_sass_tenantgroup_f_Name" :placeholder="$t('请输入')" >
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col v-if="lr_formLookAuth('lr_sass_tenantgroup_f_EnabledMark')" :span="24" >
                                    <el-form-item 
                                        :label="$t('有效')" 
                                        prop="lr_sass_tenantgroup_f_EnabledMark"
                                        > 
                                        <el-switch  :disabled="!lr_formEditAuth('lr_sass_tenantgroup_f_EnabledMark')" :activeValue="1" :inactiveValue="0" v-model="formData.lr_sass_tenantgroup_f_EnabledMark" />
                                    </el-form-item>
                                </el-col>
                                <el-col v-if="lr_formLookAuth('lr_sass_tenantgroup_f_Description')" :span="24" >
                                    <el-form-item 
                                        :label="$t('备注')" 
                                        prop="lr_sass_tenantgroup_f_Description"
                                        > 
                                        <el-input type="textarea"  :disabled="!lr_formEditAuth('lr_sass_tenantgroup_f_Description')" :rows="5" v-model="formData.lr_sass_tenantgroup_f_Description" :placeholder="$t('请输入')" />
                                    </el-form-item>
                                </el-col>
                            </div>
                        </el-row>
                    </el-tab-pane>

                </el-tabs>
            </div>
        </el-form>
    </div>
</template>
<script>
const api = window.$api.sass.tenantGroup

export default {
    data(){
        return {
            moduleCode: 'sass_tenantGroup',
            activeName: 'tab0',
            formData: {
                lr_sass_tenantgroup_f_Code:"", // 编码
                lr_sass_tenantgroup_f_Name:"", // 名称
                lr_sass_tenantgroup_f_EnabledMark:1, // 有效
                lr_sass_tenantgroup_f_Description:"", // 备注

            },
            rules: {
                lr_sass_tenantgroup_f_Name:[
                    { required: true, message: this.$t('请输入名称') },
                ],

            },
            
        };
    },
    computed: {
        
    },
    methods: {
        
        
        // 重置表单
        resetForm() {
            this.$formClear(this.$refs.form)
            this.activeName = 'tab0'
            
        },
        // 校验表单
        async validateForm() {
            if (!await this.$formValidateWraper(this.$refs.form)) {
                return false  
            }
            
            return true
        },
        // 设置表单数据
        setForm(data) {
            this.$setFormData(this.formData,data,'lr_sass_tenantgroup')

        },
        // 获取表单数据
        getForm() {
            return this.$getFormData(this.formData,'lr_sass_tenantgroup')

        },

        async loadFormData({ keyValue/*,params,node*/ }) {//  keyValue 流程中相当于流程processId,params 传递参数,node 流程节点
            const data = await this.$awaitWraper(api.get(keyValue))
            if (data) {
                this.setForm(data)
                return true
            }
            else {
                return false
            }
        },

        async saveForm({ keyValue, isEdit/*,code,node*/ }) {// isEdit 是否更新数据, keyValue 流程中相当于流程processId,code 表示流程中的操作码,node 流程节点
            const postData = this.getForm()
            if (isEdit) {// 编辑
                return await this.$awaitWraper(api.update(keyValue, postData))
            }
            else {// 新增
                postData.f_Id = keyValue

                return await this.$awaitWraper(api.add(postData))
            }
        },
    }
}
</script>